/**
 * @author James Simpson
 * Website: http://www.jsblogstop.com
 */
var jsBloggerLightBox = function(){
    var $lightbox, $lightboxImg, linkImg = function(){
        var $img = $(this), $parent = $img.parent();
        
        if ($parent[0].nodeName == "A" && ($parent.attr("href").search("blogspot.com") != -1 || $parent.attr("href").search("googleusercontent.com") != -1)) {//Link around an Image
            $img.attr("title", "Click to View Full Size");				
				$img.attr("data-enlarge-src", $parent.attr("href"));
				$img.click(jsBloggerLightBox.show);
          $parent.attr("href", "javascript:void(0);");
            //$parent.attr("href", "javascript:jsBloggerLightBox.lightbox('" + $parent.attr("href") + "');");
        }
    };
    
    this.init = function(){
        $("body").prepend("<div id='js-lightbox'><img id='js-lightboxImg'/><div id='js-lightbox-close'>Close</div></div>");
        var style = "<style type='text/css'>" +
            "#js-lightbox {overflow: auto;display: none;position: fixed;top: 0;left: 0;height: 100%;width: 100%;text-align: center;z-index: 100;background: transparent url(http://www.blogblog.com/1kt/transparent/black50.png) repeat scroll top left;}" +
        "#js-lightbox img {margin: auto;position: relative;top: 10px;border: 1px solid #999999;box-shadow: 0px 0px 5px #999999;padding: 10px;background-color: #e2e2e2;max-height: 100%;width: auto;}" +
        "#js-lightbox-close {padding: 3px;margin: 10px auto;width: 80px;border: 2px solid #D2B48C;background-color: #ffffff;color: #444444;font-weight: bold;cursor: pointer;border-radius: 5px;}" +
        "</style>";
        $("head").append(style);
        $lightbox = $("#js-lightbox");
        $lightboxImg = $("#js-lightboxImg");
        $("#js-lightbox-close").click(function(){
            $lightbox.fadeOut();
        });
        $(".post-body img").each(linkImg);
    };
    this.show = function(){
	 	$lightboxImg.attr("src", $(this).attr("data-enlarge-src"));
		 $lightbox.fadeIn();
	 };
    $(document).ready(this.init);
    return this;
}();
